///*
// * To change this template, choose Tools | Templates
// * and open the template in the editor.
// */
//package ForOutputsTest;
//
//import com.nc.kyiv.yellow.sociallibrary.DataSet.GetGlobalLib;
//import com.nc.kyiv.yellow.sociallibrary.DataSet.GetLocalLib;
//import com.nc.kyiv.yellow.sociallibrary.POJO.BookAuthor;
//import com.nc.kyiv.yellow.sociallibrary.POJO.LocalLibBook;
//import com.nc.kyiv.yellow.sociallibrary.dao.BookDAO;
//import java.io.IOException;
//import java.io.PrintWriter;
//import java.util.ArrayList;
//import java.util.HashMap;
//import java.util.Map;
//import java.util.logging.Level;
//import java.util.logging.Logger;
//import javax.naming.NamingException;
//import javax.servlet.ServletException;
//import javax.servlet.http.HttpServlet;
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//
///**
// *
// * @author Alena
// */
//public class GetLocalLibServlet extends HttpServlet {
//
//    /**
//     * Processes requests for both HTTP
//     * <code>GET</code> and
//     * <code>POST</code> methods.
//     *
//     * @param request servlet request
//     * @param response servlet response
//     * @throws ServletException if a servlet-specific error occurs
//     * @throws IOException if an I/O error occurs
//     */
//    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
//            throws ServletException, IOException, NamingException, Exception {
//        response.setContentType("text/html;charset=UTF-8");
//        PrintWriter out = response.getWriter();
//        try {
//            /* TODO output your page here. You may use following sample code. */
////            BookDAO dao = new BookDAO();
////            ArrayList<LocalLibBook> localLib = new ArrayList<>();
////            ArrayList<HashMap> library = new ArrayList<>();
////            
//            /* TODO output your page here. You may use following sample code. */
//            out.println("<html>");
//            out.println("<head>");
//            out.println("<title>GetLocalLib</title>");            
//            out.println("</head>");
//            out.println("<body>");
//            
//            String params = "1;JS;10;JS;new;JS;all genres";
//            GetLocalLib ggl = new GetLocalLib("5");
//            
//            out.println(ggl.execute(params));
//            
//            
//            
////             int userId = Integer.parseInt(request.getParameter("userId"));
////             int pageNumber = Integer.parseInt(request.getParameter("pageNumber"));
////             int booksNumber = Integer.parseInt(request.getParameter("bookNumber"));
////             int cursorPosition = (pageNumber - 1)*booksNumber +1;
////             localLib = dao.getBooksFromLocalLib(userId, cursorPosition, booksNumber);
////            
//////            ArrayList<HashMap> result = bookInfoBean.getLibrary(params);
////            if (localLib != null) {
////                for (LocalLibBook llb : localLib) {
////                        out.println("ISBN: " + llb.getISBN() + "<br>");
////                        out.println("Title: " + llb.getTitle() + "<br>");
////                        out.println("Description: " + llb.getDescription() + "<br>");
////                        out.println("Number of page: " + llb.getPageNumber() + "<br>");
////                        out.println("Image: " + llb.getImageURL() + "<br>");
////                        out.println("Read status: " + llb.getReadStatus() + "<br>");
////                        out.println("<br>");
////                        ArrayList<BookAuthor> authors = llb.getAuthors();
////                        for(BookAuthor a: authors) {
////                            if (a.getMiddleName() != null){
////                                out.println("Author: " + a.getFirstName() + " " + a.getMiddleName() + " " + a.getLastName() + "<br>");
////                                } else {
////                                out.println("Author: " + a.getFirstName() + " " + a.getLastName() + "<br>");
////                            }
////                        }
////
////                        ArrayList<String> genres = llb.getGenres();
////                        for (String str: genres) {
////                        out.println("Genre: " + str + "<br>");
////                        }
////                    HashMap rating = llb.getRating();
////                        if (rating != null) {
////                            out.println("AvrScore: " + rating.get("avgRating") + "<br>");
////                            out.println("TotalScore: " + rating.get("sumRating") + "<br>");
////                            for (int j=1; j<6; j++) {
////                                if (rating.containsKey(j)) {
////                                    out.println(j + ": " + rating.get(j) + "<br>");
////                                }
////                            }
////
////                        } else { 
////                            out.println("Book does not have scores");
////                        }
////                    }
////          
////            } else{
////                out.println("Local lib doesn't exist for that user");
////            }
//            out.println("</body>");
//            out.println("</html>");
//            
//        } finally {            
//            out.close();
//        }
//    }
//
//    // <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
//    /**
//     * Handles the HTTP
//     * <code>GET</code> method.
//     *
//     * @param request servlet request
//     * @param response servlet response
//     * @throws ServletException if a servlet-specific error occurs
//     * @throws IOException if an I/O error occurs
//     */
//    @Override
//    protected void doGet(HttpServletRequest request, HttpServletResponse response)
//            throws ServletException, IOException {
//        try {
//            processRequest(request, response);
//        } catch (NamingException ex) {
//            Logger.getLogger(GetLocalLibServlet.class.getName()).log(Level.SEVERE, null, ex);
//        } catch (Exception ex) {
//            Logger.getLogger(GetLocalLibServlet.class.getName()).log(Level.SEVERE, null, ex);
//        }
//    }
//
//    /**
//     * Handles the HTTP
//     * <code>POST</code> method.
//     *
//     * @param request servlet request
//     * @param response servlet response
//     * @throws ServletException if a servlet-specific error occurs
//     * @throws IOException if an I/O error occurs
//     */
//    @Override
//    protected void doPost(HttpServletRequest request, HttpServletResponse response)
//            throws ServletException, IOException {
//        try {
//            processRequest(request, response);
//        } catch (NamingException ex) {
//            Logger.getLogger(GetLocalLibServlet.class.getName()).log(Level.SEVERE, null, ex);
//        } catch (Exception ex) {
//            Logger.getLogger(GetLocalLibServlet.class.getName()).log(Level.SEVERE, null, ex);
//        }
//    }
//
//    /**
//     * Returns a short description of the servlet.
//     *
//     * @return a String containing servlet description
//     */
//    @Override
//    public String getServletInfo() {
//        return "Short description";
//    }// </editor-fold>
//}
